<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.17"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>BadgerDB: /home/ubuntu/study/dbmslab/lab2/BufMgr/src/page.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">BadgerDB
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_43e0a1f539e00dcfa1a6bc4d4fee4fc2.html">home</a></li><li class="navelem"><a class="el" href="dir_f895279abf3c9abddbac24b9a320b4c6.html">ubuntu</a></li><li class="navelem"><a class="el" href="dir_9223221a80e1dde112a2f0d1c0d6bc8d.html">study</a></li><li class="navelem"><a class="el" href="dir_565d95caf30f979632cef261ad9a6ed4.html">dbmslab</a></li><li class="navelem"><a class="el" href="dir_04bc7b587b42191e49c8f970037360ad.html">lab2</a></li><li class="navelem"><a class="el" href="dir_ccc57109e70d5b9b219c75d9ecb5bc70.html">BufMgr</a></li><li class="navelem"><a class="el" href="dir_57419356550b183f8cb4d89f81ab51b6.html">src</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">page.h</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160; </div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="preprocessor">#pragma once</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160; </div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="preprocessor">#include &lt;cstddef&gt;</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="preprocessor">#include &lt;stdint.h&gt;</span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="preprocessor">#include &lt;memory&gt;</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="preprocessor">#include &lt;string&gt;</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160; </div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="preprocessor">#include &quot;types.h&quot;</span></div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160; </div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacebadgerdb.html">badgerdb</a> {</div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160; </div>
<div class="line"><a name="l00025"></a><span class="lineno"><a class="line" href="structbadgerdb_1_1_page_header.html">   25</a></span>&#160;<span class="keyword">struct </span><a class="code" href="structbadgerdb_1_1_page_header.html">PageHeader</a> {</div>
<div class="line"><a name="l00030"></a><span class="lineno"><a class="line" href="structbadgerdb_1_1_page_header.html#ac71c5a9b3b8644da0ea827f5bd4c5742">   30</a></span>&#160;  std::uint16_t <a class="code" href="structbadgerdb_1_1_page_header.html#ac71c5a9b3b8644da0ea827f5bd4c5742">free_space_lower_bound</a>;</div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160; </div>
<div class="line"><a name="l00036"></a><span class="lineno"><a class="line" href="structbadgerdb_1_1_page_header.html#a3af3c066d7651294fb3aae104f404648">   36</a></span>&#160;  std::uint16_t <a class="code" href="structbadgerdb_1_1_page_header.html#a3af3c066d7651294fb3aae104f404648">free_space_upper_bound</a>;</div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160; </div>
<div class="line"><a name="l00043"></a><span class="lineno"><a class="line" href="structbadgerdb_1_1_page_header.html#a6c233369c611cfb617ba676e11a9d87d">   43</a></span>&#160;  <a class="code" href="namespacebadgerdb.html#afe9f2f985e7c67e04f76a16f7c4500c8">SlotId</a> <a class="code" href="structbadgerdb_1_1_page_header.html#a6c233369c611cfb617ba676e11a9d87d">num_slots</a>;</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160; </div>
<div class="line"><a name="l00048"></a><span class="lineno"><a class="line" href="structbadgerdb_1_1_page_header.html#a7afd8d3c6f22b25e24958ebef773175e">   48</a></span>&#160;  <a class="code" href="namespacebadgerdb.html#afe9f2f985e7c67e04f76a16f7c4500c8">SlotId</a> <a class="code" href="structbadgerdb_1_1_page_header.html#a7afd8d3c6f22b25e24958ebef773175e">num_free_slots</a>;</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160; </div>
<div class="line"><a name="l00053"></a><span class="lineno"><a class="line" href="structbadgerdb_1_1_page_header.html#a3f721c5ce9ef491fdc9d12292f2f4498">   53</a></span>&#160;  <a class="code" href="namespacebadgerdb.html#a1f49e404293bf4240756b89b53b1587a">PageId</a> <a class="code" href="structbadgerdb_1_1_page_header.html#a3f721c5ce9ef491fdc9d12292f2f4498">current_page_number</a>;</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160; </div>
<div class="line"><a name="l00058"></a><span class="lineno"><a class="line" href="structbadgerdb_1_1_page_header.html#a7cb8260dedb0748d3d75c4b1722dcf3c">   58</a></span>&#160;  <a class="code" href="namespacebadgerdb.html#a1f49e404293bf4240756b89b53b1587a">PageId</a> <a class="code" href="structbadgerdb_1_1_page_header.html#a7cb8260dedb0748d3d75c4b1722dcf3c">next_page_number</a>;</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160; </div>
<div class="line"><a name="l00066"></a><span class="lineno"><a class="line" href="structbadgerdb_1_1_page_header.html#a57c325ad3552a01e24fcb01b415d7763">   66</a></span>&#160;  <span class="keywordtype">bool</span> <a class="code" href="structbadgerdb_1_1_page_header.html#a57c325ad3552a01e24fcb01b415d7763">operator==</a>(<span class="keyword">const</span> <a class="code" href="structbadgerdb_1_1_page_header.html">PageHeader</a>&amp; rhs)<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="structbadgerdb_1_1_page_header.html#a6c233369c611cfb617ba676e11a9d87d">num_slots</a> == rhs.<a class="code" href="structbadgerdb_1_1_page_header.html#a6c233369c611cfb617ba676e11a9d87d">num_slots</a> &amp;&amp;</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;        <a class="code" href="structbadgerdb_1_1_page_header.html#a7afd8d3c6f22b25e24958ebef773175e">num_free_slots</a> == rhs.<a class="code" href="structbadgerdb_1_1_page_header.html#a7afd8d3c6f22b25e24958ebef773175e">num_free_slots</a> &amp;&amp;</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;        <a class="code" href="structbadgerdb_1_1_page_header.html#a3f721c5ce9ef491fdc9d12292f2f4498">current_page_number</a> == rhs.<a class="code" href="structbadgerdb_1_1_page_header.html#a3f721c5ce9ef491fdc9d12292f2f4498">current_page_number</a> &amp;&amp;</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;        <a class="code" href="structbadgerdb_1_1_page_header.html#a7cb8260dedb0748d3d75c4b1722dcf3c">next_page_number</a> == rhs.<a class="code" href="structbadgerdb_1_1_page_header.html#a7cb8260dedb0748d3d75c4b1722dcf3c">next_page_number</a>;</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;  }</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;};</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160; </div>
<div class="line"><a name="l00077"></a><span class="lineno"><a class="line" href="structbadgerdb_1_1_page_slot.html">   77</a></span>&#160;<span class="keyword">struct </span><a class="code" href="structbadgerdb_1_1_page_slot.html">PageSlot</a> {</div>
<div class="line"><a name="l00082"></a><span class="lineno"><a class="line" href="structbadgerdb_1_1_page_slot.html#a4ea5ad6e73525244bb368181f21fd018">   82</a></span>&#160;  <span class="keywordtype">bool</span> <a class="code" href="structbadgerdb_1_1_page_slot.html#a4ea5ad6e73525244bb368181f21fd018">used</a>;</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160; </div>
<div class="line"><a name="l00087"></a><span class="lineno"><a class="line" href="structbadgerdb_1_1_page_slot.html#a81c14b0e942b0d59e6ac31667d958b79">   87</a></span>&#160;  std::uint16_t <a class="code" href="structbadgerdb_1_1_page_slot.html#a81c14b0e942b0d59e6ac31667d958b79">item_offset</a>;</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160; </div>
<div class="line"><a name="l00092"></a><span class="lineno"><a class="line" href="structbadgerdb_1_1_page_slot.html#a675118fb03cd9e1b35970a1f10bda9d8">   92</a></span>&#160;  std::uint16_t <a class="code" href="structbadgerdb_1_1_page_slot.html#a675118fb03cd9e1b35970a1f10bda9d8">item_length</a>;</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;};</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160; </div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;<span class="keyword">class </span><a class="code" href="classbadgerdb_1_1_page_iterator.html">PageIterator</a>;</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160; </div>
<div class="line"><a name="l00107"></a><span class="lineno"><a class="line" href="classbadgerdb_1_1_page.html">  107</a></span>&#160;<span class="keyword">class </span><a class="code" href="classbadgerdb_1_1_page.html">Page</a> {</div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160; <span class="keyword">public</span>:</div>
<div class="line"><a name="l00113"></a><span class="lineno"><a class="line" href="classbadgerdb_1_1_page.html#ae92d52803502854f97309bae2c14ea55">  113</a></span>&#160;  <span class="keyword">static</span> <span class="keyword">const</span> std::size_t <a class="code" href="classbadgerdb_1_1_page.html#ae92d52803502854f97309bae2c14ea55">SIZE</a> = 8192;</div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160; </div>
<div class="line"><a name="l00118"></a><span class="lineno"><a class="line" href="classbadgerdb_1_1_page.html#a74057ec71412352ef0aa5913bbebed25">  118</a></span>&#160;  <span class="keyword">static</span> <span class="keyword">const</span> std::size_t <a class="code" href="classbadgerdb_1_1_page.html#a74057ec71412352ef0aa5913bbebed25">DATA_SIZE</a> = <a class="code" href="classbadgerdb_1_1_page.html#ae92d52803502854f97309bae2c14ea55">SIZE</a> - <span class="keyword">sizeof</span>(<a class="code" href="structbadgerdb_1_1_page_header.html">PageHeader</a>);</div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160; </div>
<div class="line"><a name="l00123"></a><span class="lineno"><a class="line" href="classbadgerdb_1_1_page.html#a785a1e756d47fb7f8f3603a3fe8ffcef">  123</a></span>&#160;  <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="namespacebadgerdb.html#a1f49e404293bf4240756b89b53b1587a">PageId</a> <a class="code" href="classbadgerdb_1_1_page.html#a785a1e756d47fb7f8f3603a3fe8ffcef">INVALID_NUMBER</a> = 0;</div>
<div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160; </div>
<div class="line"><a name="l00128"></a><span class="lineno"><a class="line" href="classbadgerdb_1_1_page.html#a4013fab43df72bc52931241575736353">  128</a></span>&#160;  <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="namespacebadgerdb.html#afe9f2f985e7c67e04f76a16f7c4500c8">SlotId</a> <a class="code" href="classbadgerdb_1_1_page.html#a4013fab43df72bc52931241575736353">INVALID_SLOT</a> = 0;</div>
<div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160; </div>
<div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;  <a class="code" href="classbadgerdb_1_1_page.html#a1e4a3930a92ed6e71ffd253cf224379a">Page</a>();</div>
<div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160; </div>
<div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;  <a class="code" href="structbadgerdb_1_1_record_id.html">RecordId</a> <a class="code" href="classbadgerdb_1_1_page.html#ad0b1e85fe7849fb767dd8c21a8053cf4">insertRecord</a>(<span class="keyword">const</span> std::string&amp; record_data);</div>
<div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160; </div>
<div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;  std::string <a class="code" href="classbadgerdb_1_1_page.html#aad81fa59b469866fbd260c8a640b579f">getRecord</a>(<span class="keyword">const</span> <a class="code" href="structbadgerdb_1_1_record_id.html">RecordId</a>&amp; record_id) <span class="keyword">const</span>;</div>
<div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160; </div>
<div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classbadgerdb_1_1_page.html#ae24e3f6076d6c0a18d4dd2014d540bab">updateRecord</a>(<span class="keyword">const</span> <a class="code" href="structbadgerdb_1_1_record_id.html">RecordId</a>&amp; record_id, <span class="keyword">const</span> std::string&amp; record_data);</div>
<div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160; </div>
<div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classbadgerdb_1_1_page.html#a1bc17754b4ed548f8520a6274b3a4202">deleteRecord</a>(<span class="keyword">const</span> <a class="code" href="structbadgerdb_1_1_record_id.html">RecordId</a>&amp; record_id);</div>
<div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160; </div>
<div class="line"><a name="l00178"></a><span class="lineno">  178</span>&#160;  <span class="keywordtype">bool</span> <a class="code" href="classbadgerdb_1_1_page.html#a059cb59e3ba05921f9c648fb5dba1068">hasSpaceForRecord</a>(<span class="keyword">const</span> std::string&amp; record_data) <span class="keyword">const</span>;</div>
<div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160; </div>
<div class="line"><a name="l00185"></a><span class="lineno"><a class="line" href="classbadgerdb_1_1_page.html#a6f8c9e50538db4d88306b77c214c09dd">  185</a></span>&#160;  std::uint16_t <a class="code" href="classbadgerdb_1_1_page.html#a6f8c9e50538db4d88306b77c214c09dd">getFreeSpace</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a3af3c066d7651294fb3aae104f404648">free_space_upper_bound</a> -</div>
<div class="line"><a name="l00186"></a><span class="lineno">  186</span>&#160;                                              header_.<a class="code" href="structbadgerdb_1_1_page_header.html#ac71c5a9b3b8644da0ea827f5bd4c5742">free_space_lower_bound</a>; }</div>
<div class="line"><a name="l00187"></a><span class="lineno">  187</span>&#160; </div>
<div class="line"><a name="l00193"></a><span class="lineno"><a class="line" href="classbadgerdb_1_1_page.html#af8416fd0be779f473c97b47e797e1c53">  193</a></span>&#160;  <a class="code" href="namespacebadgerdb.html#a1f49e404293bf4240756b89b53b1587a">PageId</a> <a class="code" href="classbadgerdb_1_1_page.html#af8416fd0be779f473c97b47e797e1c53">page_number</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a3f721c5ce9ef491fdc9d12292f2f4498">current_page_number</a>; }</div>
<div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160; </div>
<div class="line"><a name="l00200"></a><span class="lineno"><a class="line" href="classbadgerdb_1_1_page.html#a9524d4507a600c1bd55bdc5b9511a484">  200</a></span>&#160;  <a class="code" href="namespacebadgerdb.html#a1f49e404293bf4240756b89b53b1587a">PageId</a> <a class="code" href="classbadgerdb_1_1_page.html#a9524d4507a600c1bd55bdc5b9511a484">next_page_number</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a7cb8260dedb0748d3d75c4b1722dcf3c">next_page_number</a>; }</div>
<div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160; </div>
<div class="line"><a name="l00207"></a><span class="lineno">  207</span>&#160;  <a class="code" href="classbadgerdb_1_1_page_iterator.html">PageIterator</a> <a class="code" href="classbadgerdb_1_1_page.html#aa0fdb281074cd60cb1f1d6ea6d620772">begin</a>();</div>
<div class="line"><a name="l00208"></a><span class="lineno">  208</span>&#160; </div>
<div class="line"><a name="l00215"></a><span class="lineno">  215</span>&#160;  <a class="code" href="classbadgerdb_1_1_page_iterator.html">PageIterator</a> <a class="code" href="classbadgerdb_1_1_page.html#a8e78cba69bef682a5427932485da4608">end</a>();</div>
<div class="line"><a name="l00216"></a><span class="lineno">  216</span>&#160; </div>
<div class="line"><a name="l00217"></a><span class="lineno">  217</span>&#160; <span class="keyword">private</span>:</div>
<div class="line"><a name="l00221"></a><span class="lineno">  221</span>&#160;  <span class="keywordtype">void</span> initialize();</div>
<div class="line"><a name="l00222"></a><span class="lineno">  222</span>&#160; </div>
<div class="line"><a name="l00228"></a><span class="lineno">  228</span>&#160;  <span class="keywordtype">void</span> set_page_number(<span class="keyword">const</span> <a class="code" href="namespacebadgerdb.html#a1f49e404293bf4240756b89b53b1587a">PageId</a> new_page_number) {</div>
<div class="line"><a name="l00229"></a><span class="lineno">  229</span>&#160;    header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a3f721c5ce9ef491fdc9d12292f2f4498">current_page_number</a> = new_page_number;</div>
<div class="line"><a name="l00230"></a><span class="lineno">  230</span>&#160;  }</div>
<div class="line"><a name="l00231"></a><span class="lineno">  231</span>&#160; </div>
<div class="line"><a name="l00237"></a><span class="lineno">  237</span>&#160;  <span class="keywordtype">void</span> set_next_page_number(<span class="keyword">const</span> <a class="code" href="namespacebadgerdb.html#a1f49e404293bf4240756b89b53b1587a">PageId</a> new_next_page_number) {</div>
<div class="line"><a name="l00238"></a><span class="lineno">  238</span>&#160;    header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a7cb8260dedb0748d3d75c4b1722dcf3c">next_page_number</a> = new_next_page_number;</div>
<div class="line"><a name="l00239"></a><span class="lineno">  239</span>&#160;  }</div>
<div class="line"><a name="l00240"></a><span class="lineno">  240</span>&#160; </div>
<div class="line"><a name="l00251"></a><span class="lineno">  251</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classbadgerdb_1_1_page.html#a1bc17754b4ed548f8520a6274b3a4202">deleteRecord</a>(<span class="keyword">const</span> RecordId&amp; record_id,</div>
<div class="line"><a name="l00252"></a><span class="lineno">  252</span>&#160;                    <span class="keyword">const</span> <span class="keywordtype">bool</span> allow_slot_compaction);</div>
<div class="line"><a name="l00253"></a><span class="lineno">  253</span>&#160; </div>
<div class="line"><a name="l00262"></a><span class="lineno">  262</span>&#160;  PageSlot* getSlot(<span class="keyword">const</span> <a class="code" href="namespacebadgerdb.html#afe9f2f985e7c67e04f76a16f7c4500c8">SlotId</a> slot_number);</div>
<div class="line"><a name="l00263"></a><span class="lineno">  263</span>&#160; </div>
<div class="line"><a name="l00272"></a><span class="lineno">  272</span>&#160;  <span class="keyword">const</span> PageSlot&amp; getSlot(<span class="keyword">const</span> <a class="code" href="namespacebadgerdb.html#afe9f2f985e7c67e04f76a16f7c4500c8">SlotId</a> slot_number) <span class="keyword">const</span>;</div>
<div class="line"><a name="l00273"></a><span class="lineno">  273</span>&#160; </div>
<div class="line"><a name="l00288"></a><span class="lineno">  288</span>&#160;  <a class="code" href="namespacebadgerdb.html#afe9f2f985e7c67e04f76a16f7c4500c8">SlotId</a> getAvailableSlot();</div>
<div class="line"><a name="l00289"></a><span class="lineno">  289</span>&#160; </div>
<div class="line"><a name="l00303"></a><span class="lineno">  303</span>&#160;  <span class="keywordtype">void</span> insertRecordInSlot(<span class="keyword">const</span> <a class="code" href="namespacebadgerdb.html#afe9f2f985e7c67e04f76a16f7c4500c8">SlotId</a> slot_number,</div>
<div class="line"><a name="l00304"></a><span class="lineno">  304</span>&#160;                          <span class="keyword">const</span> std::string&amp; record_data);</div>
<div class="line"><a name="l00305"></a><span class="lineno">  305</span>&#160; </div>
<div class="line"><a name="l00314"></a><span class="lineno">  314</span>&#160;  <span class="keywordtype">void</span> validateRecordId(<span class="keyword">const</span> RecordId&amp; record_id) <span class="keyword">const</span>;</div>
<div class="line"><a name="l00315"></a><span class="lineno">  315</span>&#160; </div>
<div class="line"><a name="l00321"></a><span class="lineno">  321</span>&#160;  <span class="keywordtype">bool</span> isUsed()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classbadgerdb_1_1_page.html#af8416fd0be779f473c97b47e797e1c53">page_number</a>() != <a class="code" href="classbadgerdb_1_1_page.html#a785a1e756d47fb7f8f3603a3fe8ffcef">INVALID_NUMBER</a>; }</div>
<div class="line"><a name="l00322"></a><span class="lineno">  322</span>&#160; </div>
<div class="line"><a name="l00326"></a><span class="lineno">  326</span>&#160;  PageHeader header_;</div>
<div class="line"><a name="l00327"></a><span class="lineno">  327</span>&#160; </div>
<div class="line"><a name="l00333"></a><span class="lineno">  333</span>&#160;  std::string data_;</div>
<div class="line"><a name="l00334"></a><span class="lineno">  334</span>&#160; </div>
<div class="line"><a name="l00335"></a><span class="lineno">  335</span>&#160;  <span class="keyword">friend</span> <span class="keyword">class </span>File;</div>
<div class="line"><a name="l00336"></a><span class="lineno">  336</span>&#160;  <span class="keyword">friend</span> <span class="keyword">class </span>PageIterator;</div>
<div class="line"><a name="l00337"></a><span class="lineno">  337</span>&#160;  <span class="keyword">friend</span> <span class="keyword">class </span>PageTest;</div>
<div class="line"><a name="l00338"></a><span class="lineno">  338</span>&#160;  <span class="keyword">friend</span> <span class="keyword">class </span>BufferTest;</div>
<div class="line"><a name="l00339"></a><span class="lineno">  339</span>&#160;};</div>
<div class="line"><a name="l00340"></a><span class="lineno">  340</span>&#160; </div>
<div class="line"><a name="l00341"></a><span class="lineno">  341</span>&#160;static_assert(<a class="code" href="classbadgerdb_1_1_page.html#ae92d52803502854f97309bae2c14ea55">Page::SIZE</a> &gt; <span class="keyword">sizeof</span>(PageHeader),</div>
<div class="line"><a name="l00342"></a><span class="lineno">  342</span>&#160;              <span class="stringliteral">&quot;Page size must be large enough to hold header and data.&quot;</span>);</div>
<div class="line"><a name="l00343"></a><span class="lineno">  343</span>&#160;static_assert(<a class="code" href="classbadgerdb_1_1_page.html#a74057ec71412352ef0aa5913bbebed25">Page::DATA_SIZE</a> &gt; 0,</div>
<div class="line"><a name="l00344"></a><span class="lineno">  344</span>&#160;              <span class="stringliteral">&quot;Page must have some space to hold data.&quot;</span>);</div>
<div class="line"><a name="l00345"></a><span class="lineno">  345</span>&#160; </div>
<div class="line"><a name="l00346"></a><span class="lineno">  346</span>&#160;}</div>
</div><!-- fragment --></div><!-- contents -->
<div class="ttc" id="astructbadgerdb_1_1_page_header_html_a3f721c5ce9ef491fdc9d12292f2f4498"><div class="ttname"><a href="structbadgerdb_1_1_page_header.html#a3f721c5ce9ef491fdc9d12292f2f4498">badgerdb::PageHeader::current_page_number</a></div><div class="ttdeci">PageId current_page_number</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00053">page.h:53</a></div></div>
<div class="ttc" id="astructbadgerdb_1_1_page_slot_html"><div class="ttname"><a href="structbadgerdb_1_1_page_slot.html">badgerdb::PageSlot</a></div><div class="ttdoc">Slot metadata that tracks where a record is in the data space.</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00077">page.h:77</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html_a74057ec71412352ef0aa5913bbebed25"><div class="ttname"><a href="classbadgerdb_1_1_page.html#a74057ec71412352ef0aa5913bbebed25">badgerdb::Page::DATA_SIZE</a></div><div class="ttdeci">static const std::size_t DATA_SIZE</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00118">page.h:118</a></div></div>
<div class="ttc" id="anamespacebadgerdb_html"><div class="ttname"><a href="namespacebadgerdb.html">badgerdb</a></div><div class="ttdef"><b>Definition:</b> <a href="buffer_8cpp_source.html#l00017">buffer.cpp:17</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html_a059cb59e3ba05921f9c648fb5dba1068"><div class="ttname"><a href="classbadgerdb_1_1_page.html#a059cb59e3ba05921f9c648fb5dba1068">badgerdb::Page::hasSpaceForRecord</a></div><div class="ttdeci">bool hasSpaceForRecord(const std::string &amp;record_data) const</div><div class="ttdef"><b>Definition:</b> <a href="page_8cpp_source.html#l00125">page.cpp:125</a></div></div>
<div class="ttc" id="astructbadgerdb_1_1_page_header_html"><div class="ttname"><a href="structbadgerdb_1_1_page_header.html">badgerdb::PageHeader</a></div><div class="ttdoc">Header metadata in a page.</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00025">page.h:25</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html_a785a1e756d47fb7f8f3603a3fe8ffcef"><div class="ttname"><a href="classbadgerdb_1_1_page.html#a785a1e756d47fb7f8f3603a3fe8ffcef">badgerdb::Page::INVALID_NUMBER</a></div><div class="ttdeci">static const PageId INVALID_NUMBER</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00123">page.h:123</a></div></div>
<div class="ttc" id="astructbadgerdb_1_1_page_header_html_ac71c5a9b3b8644da0ea827f5bd4c5742"><div class="ttname"><a href="structbadgerdb_1_1_page_header.html#ac71c5a9b3b8644da0ea827f5bd4c5742">badgerdb::PageHeader::free_space_lower_bound</a></div><div class="ttdeci">std::uint16_t free_space_lower_bound</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00030">page.h:30</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html_a1bc17754b4ed548f8520a6274b3a4202"><div class="ttname"><a href="classbadgerdb_1_1_page.html#a1bc17754b4ed548f8520a6274b3a4202">badgerdb::Page::deleteRecord</a></div><div class="ttdeci">void deleteRecord(const RecordId &amp;record_id)</div><div class="ttdef"><b>Definition:</b> <a href="page_8cpp_source.html#l00066">page.cpp:66</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html_ae92d52803502854f97309bae2c14ea55"><div class="ttname"><a href="classbadgerdb_1_1_page.html#ae92d52803502854f97309bae2c14ea55">badgerdb::Page::SIZE</a></div><div class="ttdeci">static const std::size_t SIZE</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00113">page.h:113</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html_ad0b1e85fe7849fb767dd8c21a8053cf4"><div class="ttname"><a href="classbadgerdb_1_1_page.html#ad0b1e85fe7849fb767dd8c21a8053cf4">badgerdb::Page::insertRecord</a></div><div class="ttdeci">RecordId insertRecord(const std::string &amp;record_data)</div><div class="ttdef"><b>Definition:</b> <a href="page_8cpp_source.html#l00033">page.cpp:33</a></div></div>
<div class="ttc" id="astructbadgerdb_1_1_record_id_html"><div class="ttname"><a href="structbadgerdb_1_1_record_id.html">badgerdb::RecordId</a></div><div class="ttdoc">Identifier for a record in a page.</div><div class="ttdef"><b>Definition:</b> <a href="types_8h_source.html#l00030">types.h:30</a></div></div>
<div class="ttc" id="astructbadgerdb_1_1_page_header_html_a7afd8d3c6f22b25e24958ebef773175e"><div class="ttname"><a href="structbadgerdb_1_1_page_header.html#a7afd8d3c6f22b25e24958ebef773175e">badgerdb::PageHeader::num_free_slots</a></div><div class="ttdeci">SlotId num_free_slots</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00048">page.h:48</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html_aa0fdb281074cd60cb1f1d6ea6d620772"><div class="ttname"><a href="classbadgerdb_1_1_page.html#aa0fdb281074cd60cb1f1d6ea6d620772">badgerdb::Page::begin</a></div><div class="ttdeci">PageIterator begin()</div><div class="ttdef"><b>Definition:</b> <a href="page_8cpp_source.html#l00196">page.cpp:196</a></div></div>
<div class="ttc" id="astructbadgerdb_1_1_page_header_html_a7cb8260dedb0748d3d75c4b1722dcf3c"><div class="ttname"><a href="structbadgerdb_1_1_page_header.html#a7cb8260dedb0748d3d75c4b1722dcf3c">badgerdb::PageHeader::next_page_number</a></div><div class="ttdeci">PageId next_page_number</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00058">page.h:58</a></div></div>
<div class="ttc" id="astructbadgerdb_1_1_page_header_html_a6c233369c611cfb617ba676e11a9d87d"><div class="ttname"><a href="structbadgerdb_1_1_page_header.html#a6c233369c611cfb617ba676e11a9d87d">badgerdb::PageHeader::num_slots</a></div><div class="ttdeci">SlotId num_slots</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00043">page.h:43</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html_af8416fd0be779f473c97b47e797e1c53"><div class="ttname"><a href="classbadgerdb_1_1_page.html#af8416fd0be779f473c97b47e797e1c53">badgerdb::Page::page_number</a></div><div class="ttdeci">PageId page_number() const</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00193">page.h:193</a></div></div>
<div class="ttc" id="astructbadgerdb_1_1_page_header_html_a3af3c066d7651294fb3aae104f404648"><div class="ttname"><a href="structbadgerdb_1_1_page_header.html#a3af3c066d7651294fb3aae104f404648">badgerdb::PageHeader::free_space_upper_bound</a></div><div class="ttdeci">std::uint16_t free_space_upper_bound</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00036">page.h:36</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html_ae24e3f6076d6c0a18d4dd2014d540bab"><div class="ttname"><a href="classbadgerdb_1_1_page.html#ae24e3f6076d6c0a18d4dd2014d540bab">badgerdb::Page::updateRecord</a></div><div class="ttdeci">void updateRecord(const RecordId &amp;record_id, const std::string &amp;record_data)</div><div class="ttdef"><b>Definition:</b> <a href="page_8cpp_source.html#l00049">page.cpp:49</a></div></div>
<div class="ttc" id="anamespacebadgerdb_html_a1f49e404293bf4240756b89b53b1587a"><div class="ttname"><a href="namespacebadgerdb.html#a1f49e404293bf4240756b89b53b1587a">badgerdb::PageId</a></div><div class="ttdeci">std::uint32_t PageId</div><div class="ttdoc">Identifier for a page in a file.</div><div class="ttdef"><b>Definition:</b> <a href="types_8h_source.html#l00015">types.h:15</a></div></div>
<div class="ttc" id="astructbadgerdb_1_1_page_slot_html_a675118fb03cd9e1b35970a1f10bda9d8"><div class="ttname"><a href="structbadgerdb_1_1_page_slot.html#a675118fb03cd9e1b35970a1f10bda9d8">badgerdb::PageSlot::item_length</a></div><div class="ttdeci">std::uint16_t item_length</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00092">page.h:92</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html_a6f8c9e50538db4d88306b77c214c09dd"><div class="ttname"><a href="classbadgerdb_1_1_page.html#a6f8c9e50538db4d88306b77c214c09dd">badgerdb::Page::getFreeSpace</a></div><div class="ttdeci">std::uint16_t getFreeSpace() const</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00185">page.h:185</a></div></div>
<div class="ttc" id="astructbadgerdb_1_1_page_slot_html_a4ea5ad6e73525244bb368181f21fd018"><div class="ttname"><a href="structbadgerdb_1_1_page_slot.html#a4ea5ad6e73525244bb368181f21fd018">badgerdb::PageSlot::used</a></div><div class="ttdeci">bool used</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00082">page.h:82</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html_a9524d4507a600c1bd55bdc5b9511a484"><div class="ttname"><a href="classbadgerdb_1_1_page.html#a9524d4507a600c1bd55bdc5b9511a484">badgerdb::Page::next_page_number</a></div><div class="ttdeci">PageId next_page_number() const</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00200">page.h:200</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html"><div class="ttname"><a href="classbadgerdb_1_1_page.html">badgerdb::Page</a></div><div class="ttdoc">Class which represents a fixed-size database page containing records.</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00107">page.h:107</a></div></div>
<div class="ttc" id="anamespacebadgerdb_html_afe9f2f985e7c67e04f76a16f7c4500c8"><div class="ttname"><a href="namespacebadgerdb.html#afe9f2f985e7c67e04f76a16f7c4500c8">badgerdb::SlotId</a></div><div class="ttdeci">std::uint16_t SlotId</div><div class="ttdoc">Identifier for a slot in a page.</div><div class="ttdef"><b>Definition:</b> <a href="types_8h_source.html#l00020">types.h:20</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html_aad81fa59b469866fbd260c8a640b579f"><div class="ttname"><a href="classbadgerdb_1_1_page.html#aad81fa59b469866fbd260c8a640b579f">badgerdb::Page::getRecord</a></div><div class="ttdeci">std::string getRecord(const RecordId &amp;record_id) const</div><div class="ttdef"><b>Definition:</b> <a href="page_8cpp_source.html#l00043">page.cpp:43</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_iterator_html"><div class="ttname"><a href="classbadgerdb_1_1_page_iterator.html">badgerdb::PageIterator</a></div><div class="ttdoc">Iterator for iterating over the records in a page.</div><div class="ttdef"><b>Definition:</b> <a href="page__iterator_8h_source.html#l00023">page_iterator.h:23</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html_a8e78cba69bef682a5427932485da4608"><div class="ttname"><a href="classbadgerdb_1_1_page.html#a8e78cba69bef682a5427932485da4608">badgerdb::Page::end</a></div><div class="ttdeci">PageIterator end()</div><div class="ttdef"><b>Definition:</b> <a href="page_8cpp_source.html#l00200">page.cpp:200</a></div></div>
<div class="ttc" id="astructbadgerdb_1_1_page_header_html_a57c325ad3552a01e24fcb01b415d7763"><div class="ttname"><a href="structbadgerdb_1_1_page_header.html#a57c325ad3552a01e24fcb01b415d7763">badgerdb::PageHeader::operator==</a></div><div class="ttdeci">bool operator==(const PageHeader &amp;rhs) const</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00066">page.h:66</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html_a1e4a3930a92ed6e71ffd253cf224379a"><div class="ttname"><a href="classbadgerdb_1_1_page.html#a1e4a3930a92ed6e71ffd253cf224379a">badgerdb::Page::Page</a></div><div class="ttdeci">Page()</div><div class="ttdef"><b>Definition:</b> <a href="page_8cpp_source.html#l00019">page.cpp:19</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html_a4013fab43df72bc52931241575736353"><div class="ttname"><a href="classbadgerdb_1_1_page.html#a4013fab43df72bc52931241575736353">badgerdb::Page::INVALID_SLOT</a></div><div class="ttdeci">static const SlotId INVALID_SLOT</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00128">page.h:128</a></div></div>
<div class="ttc" id="astructbadgerdb_1_1_page_slot_html_a81c14b0e942b0d59e6ac31667d958b79"><div class="ttname"><a href="structbadgerdb_1_1_page_slot.html#a81c14b0e942b0d59e6ac31667d958b79">badgerdb::PageSlot::item_offset</a></div><div class="ttdeci">std::uint16_t item_offset</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00087">page.h:87</a></div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.17
</small></address>
</body>
</html>
